#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
# @Time: 2023/12/4 14:04
# @Author: Anthony (anthony66888@163.com)
# @description: 
"""
import datetime
import time
from collections import Counter

import requests

from auto_battle_room import YamlControl


def reverse_data(data):
    if isinstance(data, str):
        return data[::-1]
    elif isinstance(data, list):
        return [reverse_data(item) for item in reversed(data)]
    elif isinstance(data, tuple):
        return tuple(reverse_data(item) for item in reversed(data))
    elif isinstance(data, set):
        return {reverse_data(item) for item in data}
    elif isinstance(data, dict):
        return {reverse_data(key): reverse_data(value) for key, value in data.items()}
    elif isinstance(data, int):
        return int(str(data)[::-1])
    else:
        return data


# res = reverse_data({'a': [1, 2, 3], 'b': 'hello'})
# print(res)

class UserInfo:
    def __init__(self):
        """获取"""
        self.config_data = YamlControl("/data/config.yaml").read_yaml()  # 读取配置项
        self.host = self.config_data["admin_host"]  # 获取环境域名
        self.token = self.config_data["admin_token"]  # 获取后台token

        self.post_headers = {
            "Token": self.token,
            "Content-Type": "application/x-www-form-urlencoded",
            "Currentroleid": "7"
        }
        self.get_headers = {
            "Token": self.token,
            "Currentroleid": "7"
        }

    def get_uid(self):
        """获取用户ID"""
        url = "/api/sys/user/customer/page"
        data = {
            "channelId": -1,
            "customerType": 0,
            "page": 1,
            "pageSize": 15000,
            "current": 1
        }
        response = requests.get(url=self.host + url, params=data, headers=self.get_headers)
        uid_list = []
        for user in response.json()["data"]["pageData"]:
            if user["inviterId"] == "12280":
                uid_list.append(user["id"])
        return uid_list

    def create_steam_gift(self, market_name):
        url = '/api/sys/item/item/add'
        data = {
            "appid": 730,
            "marketName": market_name,
            "marketHashName": market_name,
            "remark": "魔力幻方专用"
        }
        response = requests.post(url=self.host + url, data=data, headers=self.post_headers)
        return response.json()

    def batch_create_steam_gift(self, num):
        cyberpunk_names_cn = [
            "霓虹之影", "赛博边缘", "虚拟幻影", "合成之怒",
            "铬之新星", "科技融合", "数字漩涡", "神经迁移",
            "全息幽灵", "赛博裂隙", "量子脉冲", "合成烈焰",
            "数据风暴", "像素矩阵", "欧米茄核心", "纳米涌动",
            "赛博亮度", "虚拟辉光", "霓虹注入", "量子火花",
            "合成六边形", "超空间涌动", "科技黑暗", "未来回音",
            "生动电路", "赛博脉冲", "合成波涛", "未来故障",
            "量子顶点", "电路熔断器", "超驱融合", "霓虹核心",
            "赛博黎明", "虚拟薄雾", "合成火焰", "数据流动",
            "霓虹新星", "量子变迁", "数字梦境", "全息地平线",
            "赛博天空", "漩涡视野", "合成时代", "量子编码",
            "霓虹脉冲", "科技烈焰", "赛博空间奥德赛", "合成涌动",
            "太阳神裂隙", "虚拟速度", "量子纠缠", "霓虹风暴",
            "铬之赛博核心", "合成矩阵", "数据流蓬勃发展", "神经核心",
            "全息脉冲", "生动漩涡", "赛博融合", "无量法轮",
            "合成回音", "超驱转变", "科技核心", "霓虹波动",
            "赛博特隆之焰", "虚拟涌动", "合成地平线", "数据流动纪元"
        ]
        for market_name in cyberpunk_names_cn:
            self.create_steam_gift(market_name)
            time.sleep(1)
        return "批量创建礼品成功"

    def get_gift_info(self, item_id):
        url = '/api/sys/item/giftTemplate/page'
        data = {
            "page": 1,
            "pageSize": 1000,
            "current": 1,
            "giftTemplateId": item_id
        }
        response = requests.get(url=self.host + url, params=data, headers=self.get_headers)
        return response.json()

    def update_gift_image(self):
        pass


if __name__ == '__main__':
    # user_info = UserInfo()
    # # res = user_info.get_uid()
    # # print(res)
    # # date = datetime.datetime.now()
    # # print(date)
    # user_info.batch_create_steam_gift(25)

    a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
    b = []
    c = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
    d = a+b+c
    print(d)
